import {Component, OnInit} from '@angular/core';
import { ActivatedRoute } from '@angular/router';
declare var $: any;
import { LoginService } from '../../service/loginService';
import { User } from '../../models/User';
import { Loginauth } from '../../service/loginauth';

@Component({
  selector: 'app-slidebar',
  templateUrl: './slidebar.html',
  styleUrls: ['./slidebar.css']
})
export class SlidebarComponent implements OnInit {
  user: User;
  isAdmin: boolean;
  isGuest: boolean;
  constructor(private route: ActivatedRoute, private loginService: LoginService, private loginauth: Loginauth) {

  }
  ngOnInit() {
    this.loginauth.checkAdmin().subscribe((isadmin) => {
      this.isAdmin = isadmin;
    })
    this.loginauth.checkGuest().subscribe((isguest) => {
      this.isGuest = isguest;
    })
    this.user = this.loginService.user;
    $("[data-toggle='treeview']").click(function(event) {
      event.preventDefault();
      if(!$(this).parent().hasClass('is-expanded')) {
        treeviewMenu.find("[data-toggle='treeview']").parent().removeClass('is-expanded');
      }
      $(this).parent().toggleClass('is-expanded');
    });
  }
}
